#ifndef _HALINTRPT_T_H_
#define _HALINTRPT_T_H_

/* 中断管理寄存器 */

#define SINTPND_BITS_MASK       0x7FFF
#define EINTPND_BITS_MASK       0xFFFFFF

/* Interrupt Controller register */

#define S3C2440_REG_SRCPND      0x4A000000  /* Interrupt request status */
#define S3C2440_REG_INTMOD      0x4A000004  /* Interrupt mode control */
#define S3C2440_REG_INTMSK      0x4A000008  /* Interrupt mask control */
#define S3C2440_REG_PRIORITY    0x4A00000C  /* IRQ priority control */
#define S3C2440_REG_INTPND      0x4A000010  /* Interrupt request status */
#define S3C2440_REG_INTOFFSET   0x4A000014  /* Interrupt request source offset */
#define S3C2440_REG_SUBSRCPND   0x4A000018  /* Sub source */
#define S3C2440_REG_INTSUBMSK   0x4A00001C  /* Interrupt sub mask */

/* External Interrupt Controller register */

#define S3C2440_REG_EXTINT0     0x56000088  /* External interrupt control register 0 */
#define S3C2440_REG_EXTINT1     0x5600008C  /* External interrupt control register 1 */
#define S3C2440_REG_EXTINT2     0x56000090  /* External interrupt control register 2 */
#define S3C2440_REG_EINTFLT0    0x56000094  /* Reserved */
#define S3C2440_REG_EINTFLT1    0x56000098  /* Reserved */
#define S3C2440_REG_EINTFLT2    0x5600009C  /* External interrupt filter control register 2 */
#define S3C2440_REG_EINTFLT3    0x560000A0  /* External interrupt filter control register 3 */
#define S3C2440_REG_EINTMASK    0x560000A4  /* External interrupt mask */
#define S3C2440_REG_EINTPEND    0x560000A8  /* External interrupt pending */

/* 中断类型 */

#define MAJINT_FLAG      1          /* 主中断 */
#define SUBINT_FLAG      2          /* 次级中断 */
#define EXTINT_FLAG      3          /* 外部中断 */

 /* 中断源总个数 */

#define IRQ_SRC_MAX      71        

/* 中断管理数组下标偏移 (按中断分类) */

#define MAJINT_OFFSET    0
#define SUBINT_OFFSET    32
#define EXTINT_OFFSET    47

/* 中断管理数组下标范围 (按中断分类) */

#define MAJINT_SRC_START (0 + MAJINT_OFFSET)
#define MAJINT_SRC_END   (31 + MAJINT_OFFSET)  /* 31个主中断 */
#define SUBINT_SRC_START (0 + SUBINT_OFFSET)
#define SUBINT_SRC_END   (14 + SUBINT_OFFSET)  /* 14个子中断 */
#define EXTINT_SRC_START (0 + EXTINT_OFFSET)
#define EXTINT_SRC_END   (23 + EXTINT_OFFSET)  /* 23个外部中断 */

/*  */

#define MAJINT_DESCIDX(x)      (x + MAJINT_OFFSET)
#define SUBINT_DESCIDX(x)      (x + SUBINT_OFFSET)
#define EXTINT_DESCIDX(x)      (x + EXTINT_OFFSET)

/* 中断源偏移值 */

/* 非独立中断 */

#define INTOFST_EINT4_7         4       /* External interrupt 4 – 7: 外部中断：4 ~ 7 */
#define INTOFST_EINT8_23        5       /* External interrupt 8 – 23: 外部中断：8 ~ 23 */
#define INTOFST_INT_CAM         6       /* Camera Interface: 次级中断：11, 12 */
#define INTOFST_INT_WDT_AC9     9       /* Watch-Dog timer interrupt: 次级中断：13, 14, [15:31] 保留 */
#define INTOFST_INT_UART2       15      /* UART2 Interrupt: 次级中断：6, 7, 8 */
#define INTOFST_INT_UART1       23      /* UART1 Interrupt: 次级中断：3, 4, 5 */
#define INTOFST_INT_UART0       28      /* UART0 Interrupt: 次级中断：0, 1, 2 */
#define INTOFST_INT_ADC         21      /* ADC EOC and Touch interrupt: 次级中断：9, 10 */

/* 独立主中断 */

#define INTOFST_INT_EINT0       0       /* External interrupt 0 */  
#define INTOFST_INT_EINT1       1       /* External interrupt 1 */
#define INTOFST_INT_EINT2       2       /* External interrupt 2 */
#define INTOFST_INT_EINT3       3       /* External interrupt 3 */
#define INTOFST_INT_BATT_FLT    7       /* Battery Fault interrupt */
#define INTOFST_INT_TICK        8       /* RTC Time tick interrupt */
#define INTOFST_INT_TIMER0      10      /* Timer0 interrupt */
#define INTOFST_INT_TIMER1      11      /* Timer1 interrupt */
#define INTOFST_INT_TIMER2      12      /* Timer2 interrupt */
#define INTOFST_INT_TIMER3      13      /* Timer3 interrupt */
#define INTOFST_INT_TIMER4      14      /* Timer4 interrupt */
#define INTOFST_INT_LCD         16      /* LCD interrupt */
#define INTOFST_INT_DMA0        17      /* DMA channel 0 interrupt */
#define INTOFST_INT_DMA1        18      /* DMA channel 1 interrupt */
#define INTOFST_INT_DMA2        19      /* DMA channel 2 interrupt */
#define INTOFST_INT_DMA3        20      /* DMA channel 3 interrupt */
#define INTOFST_INT_SDI         21      /* SDI interrupt */
#define INTOFST_INT_SPI0        22      /* SPI0 interrupt ARB4 */
#define INTOFST_INT_NFCON       24      /* Nand Flash Control Interrupt */
#define INTOFST_INT_USBD        25      /* USB Device interrupt */
#define INTOFST_INT_USBH        26      /* USB Host interrupt */
#define INTOFST_INT_IIC         27      /* IIC interrupt */
#define INTOFST_INT_SPI1        29      /* SPI1 interrupt */
#define INTOFST_INT_RTC         30      /* RTC alarm interrupt */

/* 外部中断 / 子中断 起始位和终止位 */

#define INTOFST_EINT4_7_S       4       /* 外部中断寄存偏移截止 */
#define INTOFST_EINT4_7_E       8       /* 外部中断寄存偏移截止 */
#define INTOFST_EINT8_23_S      8       /* 外部中断寄存偏移截止 */
#define INTOFST_EINT8_23_E      24      /* 外部中断寄存偏移截止 */
#define INTOFST_INT_CAM_S       11      /* 子中断寄存偏移截止 */
#define INTOFST_INT_CAM_E       13      /* 子中断寄存偏移截止 */
#define INTOFST_INT_WDT_AC9_S   13      /* 子中断寄存偏移截止 */
#define INTOFST_INT_WDT_AC9_E   15      /* 子中断寄存偏移截止 */
#define INTOFST_INT_UART2_S     6       /* 子中断寄存偏移截止 */
#define INTOFST_INT_UART2_E     8       /* 子中断寄存偏移截止 */
#define INTOFST_INT_UART1_S     3       /* 子中断寄存偏移截止 */
#define INTOFST_INT_UART1_E     6       /* 子中断寄存偏移截止 */
#define INTOFST_INT_UART0_S     0       /* 子中断寄存偏移截止 */
#define INTOFST_INT_UART0_E     3       /* 子中断寄存偏移截止 */
#define INTOFST_INT_ADC_S       9       /* 子中断寄存偏移截止 */
#define INTOFST_INT_ADC_E       11      /* 子中断寄存偏移截止 */

#endif
